<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/10/14
  Time: 17:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>后台管理 - 易买网</title>
    <link type="text/css" rel="stylesheet" href="../css/style.css" />
    <script type="text/javascript" src="../scripts/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="../scripts/function-manage.js"></script>

</head>


<script>
    var nowPage;
    var pageCount;

    $(function () {
        var UpdateFatherOrderState = function (fatherOrderId,state) {

            $.ajax({
                type:'POST',
                url: 'UpdateFatherOrderListForStateServlet',
                data:{
                    fatherOrderId:fatherOrderId,
                    state:state
                },
                success:function (data) {
                    if (data =="true"){
                        alert("恭喜您，修改成功！");
                    }

                    if (data == "false"){
                        alert("很抱歉，修改失败！");
                    }


                }
            })

        };

        //由于上面的列表是使用append插入的节点，所以使用选择器找不到新插入的节点
        //在用选择器之前，首先获取一边最新的dom对象，然后再寻找即可找到使用append添加的节点
        $(document).on("change",".stateselect",function () {

            var fatherOrderId = $(this).attr('id');
            var state = $(this).val();

             UpdateFatherOrderState(fatherOrderId,state);
        });




    })
</script>

<Script>
    var nowPage;
    var pageCount;

    $(function () {


        var getAllFatherOrderList = function (page) {
            $.ajax({
                type:'POST',
                url: 'getAllFatherOrderServlet',
                dataType: 'JSON',
                data:{
                    pageSize:3,
                    pageNum:page||1,
                    userNameKeyWord:$("#userNameKeyWord").val(),
                    orderIdKeyWord:$("#orderIdKeyWord").val()
                },
                success:function (data) {
                    $("#fatherOrderTable").find("tr").remove("tr");
                    $("#fatherOrderTable").append("<tr><th>ID</th><th>姓名</th> <th>价格</th><th>状态</th><th>操作</th></tr>");

                    $.each(data.fatherOrderList,function (index, obj) {
                        var $fatherOrderStr = "<tr>" +
                            "<td class='first w4 c'><a href='FatherOrderDetailsServlet?fatherOrderId="+obj.fatherorderid+"'>"+obj.fatherorderid+"</a></td>" +
                            "<td class='w1 c'>"+obj.user.username+"</td>" +
                            "<td class='w1 c'>"+obj.sum+"</td>" +
                            "<td class='w1 c'>"+
                            "<select name='fatherOrderState'class='stateselect' id='"+obj.fatherorderid+"' >" +
                            "<option value='0'>未支付</option>" +
                            "<option value='1'>已支付</option>" +
                            "<option value='2'>待审核</option>" +
                            "<option value='3'>已审核</option>" +
                            "<option value='4'>已完成</option>" +
                            "</select>"+
                            "</td>" +
                            "<td class='w1 c'><a href='FatherOrderDetailsServlet?fatherOrderId="+obj.fatherorderid+"'>管理</a> <a href='DelFatherOrderServlet?fatherOrderId="+obj.fatherorderid+"'>删除</a></td>" +
                            "</tr>";
                        $("#fatherOrderTable").append($fatherOrderStr);
                        document.getElementById(obj.fatherorderid).selectedIndex = obj.state;

                    });
                    nowPage = data.pageNum;
                    pageCount = data.totalPages;
                    $("#nowPageSpan").text(nowPage);
                    $("#countPageSpan").text(pageCount);
                }
            })
        };

        $(".pages").on("click",function () {
            var flag = $(this).attr("id");
            if (flag == "first") {
                getAllFatherOrderList(1);
            } else if (flag == "prev") {
                if (nowPage > 1 ){
                    nowPage--;
                }

                if (nowPage == 1){
                    nowPage=1;
                }

                getAllFatherOrderList(nowPage);
            } else if (flag == "next") {
                if (nowPage < pageCount){
                    nowPage++;
                }
                if (nowPage == pageCount){
                    nowPage=pageCount;
                }

                getAllFatherOrderList(nowPage);
            } else if (flag == "last") {
                getAllFatherOrderList(pageCount);
            }
        });



        getAllFatherOrderList();

        $("#searchNameButton").on("click", function () {
            getAllFatherOrderList();
        });






    })




</Script>




<body>
<div id="header" class="wrap">
    <div id="logo"><img src="../images/logo.gif" /></div>
    <div class="help"><a href="../../index.jsp">返回前台页面</a></div>
    <div class="navbar">
        <ul class="clearfix">
            <li><a href="index.jsp">首页</a></li>
            <li><a href="user.jsp">用户</a></li>
            <li><a href="product.jsp">商品</a></li>
            <li class="current"><a href="order.jsp">订单</a></li>
            <li><a href="guestbook.jsp">留言</a></li
            <li><a href="news.jsp">新闻</a></li>
        </ul>
    </div>
</div>
<div id="childNav">
    <div class="welcome wrap">
        管理员pillys您好，今天是2012-12-21，欢迎回到管理后台。
    </div>
</div>
<div id="position" class="wrap">
    您现在的位置：<a href="index.jsp">易买网</a> &gt; 管理后台
</div>
<div id="main" class="wrap">
    <div id="menu-mng" class="lefter">
        <div class="box">
            <dl>
                <dt>用户管理</dt>
                <dd><em><a href="user-add.jsp">新增</a></em><a href="user.jsp">用户管理</a></dd>
                <dt>商品信息</dt>
                <dd><em><a href="productClass-add.jsp">新增</a></em><a href="productClass.jsp">分类管理</a></dd>
                <dd><em><a href="product-add.jsp">新增</a></em><a href="product.jsp">商品管理</a></dd>
                <dt>订单管理</dt>
                <dd><a href="order.jsp">订单管理</a></dd>
                <dt>留言管理</dt>
                <dd><a href="guestbook.jsp">留言管理</a></dd>
                <dt>新闻管理</dt>
                <dd><em><a href="news-add.jsp">新增</a></em><a href="news.jsp">新闻管理</a></dd>
            </dl>
        </div>
    </div>
    <div class="main">
        <h2>订单管理</h2>
        <div class="manage">
            <div class="search">
<%--                <form method="get">--%>
                订单号：<input type="text" class="text" name="orderIdKeyWord" id="orderIdKeyWord" />
                    订货人：<input type="text" class="text" name="userNameKeyWord" id="userNameKeyWord" />
                    <label class="ui-blue"><input type="button" name="searchNameButton" id="searchNameButton" value="查询" /></label>
<%--                </form>--%>
            </div>
            <div class="spacer"></div>
            <table id="fatherOrderTable" class="list">


            </table>
            <div class="pager">
                <ul class="clearfix">

                    <li><a href="#" class="pages" id="first">首页</a></li>
                    <li><a href="#" class="pages" id="prev">上一页</a></li>
                    <li class="current">第<span id="nowPageSpan"></span>页|共<span id="countPageSpan"></span>页</li>
                    <li><a href="#" class="pages" id="next">下一页</a></li>
                    <li><a href="#" class="pages" id="last">尾页</a></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div id="footer">
    Copyright &copy; 2010 北大青鸟 All Rights Reserved. 京ICP证1000001号
</div>
</body>
</html>


